package com.itheima.String.method;

import java.util.Scanner;

/**
 * @Author 王加鑫
 * @Date 2021/4/27 16:05
 * @Version 1.0
 * 对手机号的脱敏操作
 */
public class SubstringTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true){
            System.out.println("请输入一个手机号:");
            String s = sc.nextLine();
            if(s.length() == 11){
                String start = s.substring(0,3);
                String end = s.substring(s.length() - 4);
                System.out.println("手机号为:"+start + "****" +end);
                break;
            }else {
                System.out.println("对不起您输入的手机号有误!");
            }
        }
    }
}
